package cn.com.taiji.oospub.wechat.common.wxpay.pay;

import java.io.UnsupportedEncodingException;

public class Test {
	public static void main(String[] args) throws UnsupportedEncodingException {
		/*HttpClientUtil http =new HttpClientUtil(); 
	   	HashMap<String,Object> map = new HashMap<String,Object>(); 
		map.put("appid", Configure.getAppid());
//		String att = "支付测试";
//		StringUtils.convertCharset(att, "UTF-8", "ISO-8859-1");
		map.put("attach", "zfcs");
		map.put("body", "爱你");
		map.put("mch_id", Configure.getMchid());
		map.put("nonce_str", "1add1a30ac87aa2db72f57a2375d8fe2");
		map.put("openid", "oX-0-wfOn_kusLaDW9nKtARLUWdU");
//		map.put("nonce_str", RandomStringGenerator.getRandomStringByLength(32));
		map.put("out_trade_no", "20150806125346");
		map.put("total_fee", 1);
//		String ip =  CommonTools.getIp(request);
		map.put("spbill_create_ip", "10.0.28.35");
//		System.out.println(ip);
		String notify_url="http://wxpay.wxutil.com/pub_v2/pay/notify.v2.php";
		map.put("notify_url", notify_url);
		map.put("trade_type", "JSAPI");
		String sign = Signature.getSign(map);
		System.out.println("sign:"+sign);
		map.put("sign", sign);
		
		StringBuffer sb = new StringBuffer();  
//        sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");  
		sb.append("<xml>");
        MainServlet.mapToXMLTest2(map, sb);  
        sb.append("</xml>");
        
        http = new HttpClientUtil();
        System.out.println(Configure.PAY_API);
        System.out.println(new String (sb.toString().getBytes(), "utf-8"));
        String post = http.post(Configure.PAY_API, sb.toString());
        System.out.println(post+"---------");*/
	}
	
	
	public void convertionString(String str,String code,String code2) throws UnsupportedEncodingException{  
        byte[] b = str.getBytes(code);//编码  gbk
        String sa = new String(b, code);//解码:用什么字符集编码就用什么字符集解码  
        System.out.println(sa);  
          
        b = sa.getBytes(code2);//编码  
        sa = new String(b, code2);//解码  utf-8
        System.err.println(sa);  
    }  
}
